package cn.IT.domain;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Knowledge entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "knowledge", catalog = "itsupport")
public class Knowledge implements java.io.Serializable {

	// Fields

	private Integer knowledgeId;
	private User user;
	private Type type;
	private String question;
	private String answer;
	private Date createdOn;

	// Constructors

	/** default constructor */
	public Knowledge() {
	}

	/** minimal constructor */
	public Knowledge(Type type, String question, String answer, Date createdOn) {
		this.type = type;
		this.question = question;
		this.answer = answer;
		this.createdOn = createdOn;
	}

	/** full constructor */
	public Knowledge(User user, Type type, String question, String answer,
			Date createdOn) {
		this.user = user;
		this.type = type;
		this.question = question;
		this.answer = answer;
		this.createdOn = createdOn;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "knowledgeId", unique = true, nullable = false)
	public Integer getKnowledgeId() {
		return this.knowledgeId;
	}

	public void setKnowledgeId(Integer knowledgeId) {
		this.knowledgeId = knowledgeId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "author")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "typeId", nullable = false)
	public Type getType() {
		return this.type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	@Column(name = "question", nullable = false, length = 0)
	public String getQuestion() {
		return this.question;
	}

	public void setQuestion(String question) {
		this.question = question;
	}

	@Column(name = "answer", nullable = false, length = 65535)
	public String getAnswer() {
		return this.answer;
	}

	public void setAnswer(String answer) {
		this.answer = answer;
	}

	@Column(name = "createdOn", nullable = false, length = 19)
	public Date getCreatedOn() {
		return this.createdOn;
	}

	public void setCreatedOn(Date createdOn) {
		this.createdOn = createdOn;
	}

}